<?php

declare(strict_types=1);

namespace App\Exchange\Job;

use App\Exchange\Api\WebSocketServer;
use Hyperf\AsyncQueue\Job;

class SendContractTickerJob extends Job
{
    public function __construct(public string $msg)
    {
    }

    public function handle()
    {
        $fds = redis()->sMembers('ex:contract');
        foreach ($fds as $fd) {
            try {
                WebSocketServer::sendMsg((int)$fd, 'contract_ticker', $this->msg);
            } catch (\Throwable $throwable) {
                console()->error('SendContractTickerJob---' . $throwable->getMessage());
            }
        }
    }
}
